package com.ioe.p2p;

import com.ioe.p2p.service.P2PProcessor;
import com.ioe.p2p.service.Processor;

import java.io.IOException;
import java.nio.channels.DatagramChannel;
import java.nio.channels.Selector;


/**
 * @author tanbo
 * @create 2023/10/8
 */
public class ClientMain {
    public static void main(String[] args) {
        Processor processor = P2PProcessor.getProcessor();
        try (
            DatagramChannel dc = DatagramChannel.open();
            Selector selector = Selector.open()
        ) {
            processor.init(dc, selector)
                    .begin()
                    .complete();
        } catch (Exception e) {
            processor.fail(e);
        } finally {
            processor.close();
        }
    }
}
